package com.yu8home.yu8home;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;

import java.util.Objects;

public class A {
    public static boolean useEpoll = false;

    static {
        String os = System.getProperty("os.name");
        if (Objects.nonNull(os) && os.equalsIgnoreCase("linux") && Epoll.isAvailable()) {
            useEpoll = true;
        }
    }

    public static EventLoopGroup buildBossEventLoopGroup() {
        return useEpoll ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1);
    }

    public static EventLoopGroup buildWorkerEventLoopGroup() {
        return useEpoll ? new EpollEventLoopGroup() : new NioEventLoopGroup();
    }


}
